﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using JigLibX.Physics;
using JigLibX.Collision;
using JigLibX.Geometry;
using JigLibX.Math;
using System.Xml;
using PloobsEngine.Modelo;

namespace PloobsEngine.Physics.XJigLib
{
    public class CapsuleObject : JigLibXObject
    {
        

        public CapsuleObject(float radius, float length, Matrix orientation, Vector3 position)
        {
            Body = new Body();
            CollisionSkin = new CollisionSkin(Body);
            CollisionSkin.AddPrimitive(new Capsule(Vector3.Transform(new Vector3(-0.5f, 0, 0), orientation), orientation, radius, length), (int)MaterialTable.MaterialID.BouncyNormal);
            Body.CollisionSkin = this.CollisionSkin;
            Vector3 com = SetMass(10.0f);
            Body.MoveTo(position + com, Matrix.Identity);
            CollisionSkin.ApplyLocalTransform(new Transform(-com, Matrix.Identity));
            Body.DisableBody();
            this.scale = new Vector3(radius, radius, length / 2);
        }

        public override void DeSerialize(XmlNode node, EngineStuff engine, IModelo world, Vector3 position, Matrix rotation)
        {
            throw new NotImplementedException();
        }

        public override void Serialize(XmlTextWriter writer)
        {
            throw new NotImplementedException();
        }
        public override PhysicObjectTypes PhysicObjectTypes
        {
            get { return PhysicObjectTypes.CAPSULEOBJECT; }
        }
    }
}
